<template>
  <div>
    <!--  头部  -->
    <header>
      <nav-top></nav-top>
    </header>
    <section>
      <!--   主体界面   -->
      <div class="main">
        <!--    文章界面    -->
        <div class="content">
          <div class="later-answer">
            <h2>
              我的稍后答
              <span style="color: #95998f">{{ haveLater.length }}</span>
            </h2>
            <div class="no-later-answer" v-show="!haveLater.length">
              <img src="../assets/images/no-later.png" alt="" />
              <p>还没有稍后答，<span>看看为你推荐的问题</span></p>
            </div>
            <div class="have-later-answer">
              <div v-for="(l_item, l_index) in haveLater" :key="l_index">
                <h3>{{ l_item.later_title }}</h3>
                <div class="later-article" v-show="!l_item.is_show">
                  {{ l_item.later_content_new }}
                  <span @click="openInfo(l_index)">
                    展开<i class="el-icon-arrow-down"></i>
                  </span>
                </div>
                <div
                  class="later-article-info"
                  v-html="l_item.later_content"
                  v-show="l_item.is_show"
                ></div>
                <div class="later-operate">
                  <el-button class="btn-edit" size="mini">
                    <i class="el-icon-edit"></i>写回答
                  </el-button>
                  <el-button class="btn-remove" size="mini">
                    <i class="el-icon-delete"></i>删除
                  </el-button>
                  <span>
                    {{ l_item.answer_num }} 个回答 ·
                    {{ l_item.look_num }} 个浏览
                  </span>
                  <span
                    @click="hideInfo(l_index)"
                    class="later-hide"
                    v-show="l_item.is_show"
                  >
                    收起<i class="el-icon-arrow-up"></i>
                  </span>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="content-right">
          <!--     其他功能     -->
          <div class="user-mould">
            <router-link to="./answer">
              <div>
                <img
                  src="../assets/images/write-answer.png"
                  width="40"
                  height="40"
                  alt=""
                />
                <span>写回答</span>
              </div>
            </router-link>
            <router-link to="./writing">
              <div>
                <img
                  src="../assets/images/write-essay.png"
                  width="39"
                  height="40"
                  alt=""
                />
                <span>写文章</span>
              </div>
            </router-link>
            <router-link to="./invited">
              <div>
                <img
                  src="../assets/images/invitation-answer.png"
                  width="40"
                  height="34"
                  alt=""
                />
                <span>邀我答</span>
              </div>
            </router-link>
            <router-link to="./later">
              <div>
                <img
                  src="../assets/images/process-later.png"
                  width="38"
                  height="34"
                  alt=""
                />
                <span>稍后答</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/draft-box.png"
                  width="40"
                  height="34"
                  alt=""
                />
                <span>草稿箱</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/collect-question.png"
                  width="39"
                  height="34"
                  alt=""
                />
                <span>收藏夹</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/tip-off.png"
                  width="45"
                  height="40"
                  alt=""
                />
                <span>举报中心</span>
              </div>
            </router-link>
            <router-link to="">
              <div>
                <img
                  src="../assets/images/list-rule.png"
                  width="38"
                  height="40"
                  alt=""
                />
                <span>榜单规则</span>
              </div>
            </router-link>
          </div>
          <p>
            Copyright©2019 Lawpro<br />
            沪ICP备19012546号
          </p>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  name: "forget",
  data() {
    return {
      haveLater: [
        {
          later_title: "2019 年双十一，你有哪些堪称「好物」的电子产品推荐？",
          later_content_new: "",
          later_content:
            "充电宝、快充头、快充线、路由器、耳机、键盘，各种必备好物；加湿器、破壁机各种厨房小电器充电宝、快充头、快充线、路由器、耳机、键盘，各种必备好物；加湿器、破壁机各种厨房小电器",
          is_show: false,
          answer_num: 148,
          look_num: "1,874,676"
        }
      ]
    };
  },
  mounted() {
    this.countWord();
  },
  methods: {
    countWord: function() {
      let item = this.haveLater;
      item.forEach(item => {
        item.later_content_new = item.later_content.slice(0, 60) + "...";
        //计算点赞数
      });
      this.haveLater = item;
    },
    openInfo(index) {
      this.haveLater[index].is_show = true;
    },
    hideInfo(index) {
      this.haveLater[index].is_show = false;
    },
    saveIndex(index) {
      this.is_follow = index;
    }
  }
};
</script>

<style scoped lang="less">
/*头部*/
header {
  z-index: 9999;
  position: fixed;
  top: 0;
  width: 100%;
  padding: 10px 0;
  background-color: #fff;
  box-shadow: 0 2px 2px 0 rgba(237, 237, 237, 0.4);
}
/*主体*/
section {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  padding-top: 15px;
  margin-top: 55px;
  background-color: #f6f6f6;

  .main {
    display: flex;
    justify-content: space-between;
    width: 1000px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;

    .content {
      width: 69%;
      height: 100%;
      border-radius: 2px;
      box-sizing: border-box;
      .later-answer {
        min-height: 100vh;
        height: 100%;
        box-sizing: border-box;
        background-color: #fff;
        box-shadow: 0 1px 3px rgba(26, 26, 26, 0.1);
        h2 {
          padding: 30px 15px;
          color: #333;
          border-bottom: 1px solid #f6f6f6;
        }
        .no-later-answer {
          margin-top: 100px;
          text-align: center;
          img {
            width: 50px;
            height: 50px;
            margin: 10px 0;
          }
          p {
            font-size: 15px;
            color: #95998f;
            span {
              color: #6b9147;
            }
          }
        }
        .have-later-answer {
          & > div {
            padding: 10px 20px;
            border-bottom: 1px solid #eaeaea;
            .later-article {
              margin: 10px 0;
              line-height: 20px;
              font-size: 15px;
              color: #333;
              cursor: pointer;
              &:hover {
                color: #646464;
              }
              & > span {
                margin-left: 5px;
                font-size: 14px;
                color: #999;
              }
            }
            .later-article-info {
              margin: 10px 0;
              line-height: 20px;
              font-size: 15px;
              color: #333;
            }
            .later-operate {
              display: flex;
              align-items: center;
              margin: 20px 0 10px;
              .btn-edit {
                width: 95px;
                height: 30px;
                font-size: 14px;
                color: #6b9147;
                border: 1px solid #6b9147;
              }
              .btn-remove {
                width: 95px;
                height: 30px;
                font-size: 14px;
                color: #8590a6;
                border: 1px solid #8590a6;
              }
              & > span {
                margin-left: 10px;
                font-size: 14px;
                color: #8590a6;
              }
              .later-hide {
                margin-left: auto;
                cursor: pointer;
              }
            }
          }
        }
      }
    }
    .content-right {
      width: 30%;
      .user-mould {
        display: flex;
        flex-wrap: wrap;
        padding: 10px;
        text-align: center;
        border-radius: 2px;
        background-color: #fff;
        box-shadow: 0 1px 1px 0 rgba(237, 237, 237, 0.4);
        a {
          width: 135px;
          color: #000;
          div {
            display: flex;
            flex-direction: column;
            margin: 10px 0;
            font-size: 14px;
            cursor: pointer;

            img {
              margin: 10px auto;
            }
          }
        }
      }
      & > p {
        margin-top: 10px;
        line-height: 30px;
        font-size: 15px;
        color: #7d8178;
      }
    }
  }
}
</style>
